package com.example.cardandswitch.card;

import android.os.Bundle;
import android.widget.SeekBar;

import com.example.cardandswitch.R;

import androidx.appcompat.app.AppCompatActivity;
import androidx.cardview.widget.CardView;

/**
 * app:cardBackgroundColor=""设置背景色
 * app:cardMaxElevation="" 设置Z轴最大高度值
 * app:cardUseCompatPadding="" 是否使用CompatPadding
 * app:cardPreventCornerOverlap="" 是否使用PreventCornerOverlap
 * app:contentPadding="" 内容的Padding
 * app:contentPaddingTop="" 内容的上Padding
 * app:contentPaddingLeft="" 内容的左Padding
 * app:contentPaddingRight="" 内容的右Padding
 * app:contentPaddingBottom="" 内容的下Padding
 */
public class CardActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_card);
        final CardView mCardview = findViewById(R.id.cv_cardview);
        SeekBar sb_1 = findViewById(R.id.sb_1);
        SeekBar sb_2 = findViewById(R.id.sb_2);
        SeekBar sb_3 = findViewById(R.id.sb_3);

        sb_1.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
            @Override
            public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
                mCardview.setRadius(progress);//设置圆角半径
            }

            @Override
            public void onStartTrackingTouch(SeekBar seekBar) {

            }

            @Override
            public void onStopTrackingTouch(SeekBar seekBar) {

            }
        });

        sb_2.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
            @Override
            public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
                mCardview.setCardElevation(progress);//设置阴影半径
            }

            @Override
            public void onStartTrackingTouch(SeekBar seekBar) {

            }

            @Override
            public void onStopTrackingTouch(SeekBar seekBar) {

            }
        });

        sb_3.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
            @Override
            public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
                mCardview.setContentPadding(progress, progress, progress, progress);//设置cardView中子控件和父控件的距离
            }

            @Override
            public void onStartTrackingTouch(SeekBar seekBar) {

            }

            @Override
            public void onStopTrackingTouch(SeekBar seekBar) {

            }
        });
    }
}